package com.backpackerxl.blog.web.admin;


import com.backpackerxl.blog.service.BlogsService;
import com.backpackerxl.blog.service.CommentService;
import com.backpackerxl.blog.service.TagService;
import com.backpackerxl.blog.service.TypeService;
import com.backpackerxl.blog.vomodel.BlogCount;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.List;

/**
 * Author by：Backpackersxl
 * Date: 2021/5/6/006
 * Time: 0:00
 **/
@Controller
@RequestMapping("/admin")
public class BlogViewController {
    private final TagService tagService;
    private final BlogsService blogsService;
    private final CommentService commentService;
    private final TypeService typeService;

    public BlogViewController(TagService tagService, BlogsService blogsService, CommentService commentService, TypeService typeService) {
        this.tagService = tagService;
        this.blogsService = blogsService;
        this.commentService = commentService;
        this.typeService = typeService;
    }

    @RequestMapping("/loadtypeinfo")
    @ResponseBody
    public List<BlogCount> loadTypeInfo() {
        return typeService.listTypeCount();
    }

    @RequestMapping("/loadtagsinfo")
    @ResponseBody
    public List<BlogCount> loadTagsInfo() {
        return tagService.listTypeCount();
    }

    @RequestMapping("/loadcommentinfo")
    @ResponseBody
    public List<BlogCount> loadCommentInfo() {
        return commentService.listCommentCount();
    }

    @RequestMapping("/loadblogviewsinfo")
    @ResponseBody
    public List<BlogCount> loadBlogViewsInfo() {
        return blogsService.listBlogViewCount();
    }
}
